package com.showapi.app.schedule

import com.showapi.app.service.BaseService
import com.showapi.app.service.DynamicService
import com.showapi.app.service.FlowService
import com.showapi.app.util.ConstantsOfShowapi
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.scheduling.annotation.Async
import org.springframework.scheduling.annotation.EnableAsync
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component

@Component
@EnableAsync
class TimeJobSchedule {

    @Autowired @Qualifier("dynamicService")
    DynamicService dynamicService

    @Autowired @Qualifier("flowService")
    FlowService flowService

    @Async
    @Scheduled(cron = "0/10 * *  * * ? ")
    public void run_second_10() {
        if(ConstantsOfShowapi.IS_DEV)return

        dynamicService.run_backgroud("handler.Timejob","run_second_10",[:])
    }

    @Async
    @Scheduled(cron = "0 0/1 *  * * ? ")
    public void run_minute_01() {
        if(ConstantsOfShowapi.IS_DEV)return
        dynamicService.run_backgroud("handler.Timejob","run_minute_01",[:])
    }

    @Async
    @Scheduled(cron = "0 0/5 *  * * ? ")
    public void run_minute_05() {
        if(ConstantsOfShowapi.IS_DEV)return
        dynamicService.run_backgroud("handler.Timejob","run_minute_05",[:])
    }

    @Async
    @Scheduled(cron = "0 0/10 *  * * ? ")
    public void run_minute_10() {
        if(ConstantsOfShowapi.IS_DEV)return
        dynamicService.run_backgroud("handler.Timejob","run_minute_10",[:])
    }

    @Async
    @Scheduled(cron = "0 0/30 *  * * ? ")
    public void run_minute_30() {
        if(ConstantsOfShowapi.IS_DEV)return
        dynamicService.run_backgroud("handler.Timejob","run_minute_30",[:])
    }

    @Async
    @Scheduled(cron = "0 0 0/1  * * ? ")
    public void run_minute_60() {
        if(ConstantsOfShowapi.IS_DEV)return
        dynamicService.run_backgroud("handler.Timejob","run_minute_60",[:])
    }

    @Async
    @Scheduled(cron = "0 0 0/6  * * ? ")
    public void run_hour_6() {
        if(ConstantsOfShowapi.IS_DEV)return
        dynamicService.run_backgroud("handler.Timejob","run_hour_6",[:])
    }


    @Async
    @Scheduled(cron = "0 0 0  * * ? ")
    public void run_DayJob() {
        if(ConstantsOfShowapi.IS_DEV)return
        dynamicService.run_backgroud("handler.Timejob","run_DayJob",[:])
    }


}